import request from '@/utils/request'

const apiName = "admin/permission";

export default {
  getNestedTreeList() {
    return request({
      url: `${apiName}/get-tree-all`,
      method: 'get'
    })
  },

  getList(params) {
    return request({
      url: `${apiName}/get-list`,
      method: 'get',
      params: params
    })
  },
  removeById(id) {
    return request({
      url: `${apiName}/delete/${id}`,
      method: "delete"
    })
  },
  save(menu) {
    return request({
      url: `${apiName}/save`,
      method: "post",
      data: menu
    })
  },
  update(menu) {
    return request({
      url: `${apiName}/update`,
      method: "put",
      data: menu
    })
  },
  toAssign(roleId) {
    return request({
      url: `${apiName}/get/${roleId}`,
      method: 'get'
    })
  },
  doAssign(roleId, permissionId) {
    return request({
      url: `${apiName}/Assign-permissions`,
      method: "post",
      params: {roleId, permissionId}
    })
  },
  getMenuById(id) {
    return request({
      url: `${apiName}/get-menu/${id}`,
      method: "get",
    })
  }
}
